<?php

namespace App\Controller\Admin\Sign;

use App\Controller\Admin\BaseController;
use App\Service\Sign\SignTaskService;
use Hyperf\Di\Annotation\Inject;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;

/**
 * @ApiController(prefix="admin/sign/task")
 */
class TaskController extends BaseController
{
    /**
     * @Inject()
     * @var SignTaskService
     */
    protected $signTaskService;

    /**
     * @PostApi(path="lists")
     */
    public function lists()
    {
        $params = $this->getParams();
        $data = $this->signTaskService->lists($params);
        _SUCCESS($data);
    }


    /**
     * @PostApi(path="edit")
     * @FormData(key="id",rule="required")
     * @FormData(key="point",rule="required")
     * @FormData(key="name",rule="required")
     */
    public function edit()
    {
        $params = $this->getParams();
        $this->signTaskService->edit($params->get('id'), $params->except('id'));
        _SUCCESS();
    }

    /**
     * @PostApi(path="set-field-status")
     * @FormData(key="id")
     * @FormData(key="value")
     * @FormData(key="field")
     */
    public function setFieldStatus()
    {
        $params = $this->getParams(false);
        $this->signTaskService->setFieldStatus($params->get('id'), $params->get('field'), $params->get('value'));
        _SUCCESS();
    }
}